package com.example.easymorse;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	public void sendMessage(View view) {
		EditText message = (EditText) findViewById(R.id.message);
		LinearLayout history = (LinearLayout) findViewById(R.id.history);
		history.addView(new MessageView(this, message.getText().toString()));
		message.setText("");
		final ScrollView scrollview = ((ScrollView) findViewById(R.id.scrollView1));
		scrollview.post(new Runnable() {
		    @Override
		    public void run() {
		        scrollview.fullScroll(ScrollView.FOCUS_DOWN);
		    }
		});
	}
}
